[java] Fix JSON parser EOF sentinel collision with U+FFFF#17737
Conversation
Input used (char) -1 as its EOF sentinel. That value is 0xFFFF - a valid Unicode code unit that can legitimately appear in JSON. Any string containing it was mis-reported as an unterminated string. Switch peek()/read() to return int with -1 as the sentinel (matching Reader.read()) so the sentinel cannot collide with a valid UTF-16 code unit.
PR Summary by QodoFix Java JSON EOF sentinel collision with U+FFFF
AI Description
Diagram
High-Level Assessment
Files changed (3)
|
Code Review by Qodo
Context used✅ Compliance rules (platform):
18 rules 1.
|
Avoids depending on the source file's byte encoding when reading the test.
|
Code review by qodo was updated up to the latest commit de2ada0 |
Input.EOFwas(char) -1, i.e.0xFFFF— a valid UTF-16 code unit. Any JSON string containing U+FFFF (literally or as�) was mis-reported as an unterminated string.Input.peek()/Input.read()to returnint, with-1as the EOF sentinel (matchingjava.io.Reader.read()).JsonInputcallers to handle the wider return type (cast tocharat appending/formatting sites).